package com.thoughtworks.biblioteca.controller;

import com.thoughtworks.biblioteca.model.Movie;
import com.thoughtworks.biblioteca.dao.MovieDao;

import java.util.List;


public class MovieController {

    private MovieDao movieDao;

    public String getMoviePrintBodyFrom(List<Movie> movies) {
        StringBuffer bf = new StringBuffer("");
        bf.append("   Movie Name");
        bf.append("                   Director");
        bf.append("             Rating \n");


        for (Movie movie : movies) {
            bf.append(movie.getName()).append("       ");
            bf.append(movie.getDirector()).append("            ");
            bf.append(movie.getRate()).append(" \n");

        }

        return bf.toString();
    }

    public void showBooks() {
        System.out.println(getMoviePrintBodyFrom(movieDao.getAllMovies()));
    }

    public MovieDao getMovieDao() {
        return movieDao;
    }

    public void setMovieDao(MovieDao movieDao) {
        this.movieDao = movieDao;
    }
}
